import request from '../utils/request'

export const getLunbo = () => {
  return request({
    method: 'get',
    url: '/api/getlunbo'
  })
}

export const getGrids = () => {
  return request({
    method: 'get',
    url: '/api/grids'
  })
}

export const getNewsList = () => {
  return request({
    method: 'get',
    url: '/api/getnewslist'
  })
}
export const getNewsInfo = id => {
  return request({
    method: 'get',
    url: '/api/getnew/' + id
  })
}
/**
 * 请求评论信息
 * @param {number} id   id
 * @param {number} page 页码
 * @param {number} pageSize 每一页的条数
 * @returns null
 */
export const getComments = ({ id, page, pageSize }) => {
  return request({
    method: 'get',
    url: `/api/getcomments/${id}?pageindex=${page}&limit=${pageSize}`
  })
}

/**
 * 发表评论
 * @param {number} id   id
 * @param {string} content 评论内容
 * @returns null
 */
export const postComment = (id, content) => {
  return request({
    method: 'post',
    url: `/api/postcomment/${id}`,
    data: {
      content
    }
  })
}

export const getImageCategory = () => {
  return request({
    method: 'get',
    url: '/api/getimgcategory'
  })
}

export const getImages = id => {
  return request({
    method: 'get',
    url: `/api/getimages/${id}`
  })
}

export const getImageInfo = id => {
  return request({
    method: 'get',
    url: `/api/getimageInfo/${id}`
  })
}

export const getThumImages = id => {
  return request({
    method: 'get',
    url: `/api/getthumimages/${id}`
  })
}

/**
 * 请求评论信息
 * @param {number} page 页码
 * @param {number} pageSize 每一页的条数
 * @returns null
 */
export const getGoods = ({ page, pageSize }) => {
  return request({
    method: 'get',
    url: `/api/getgoods?pageindex=${page}&limit=${pageSize}`
  })
}

export const getGoodsInfo = id => {
  return request({
    method: 'get',
    url: `/api/goods/getinfo/${id}`
  })
}